<?php
$this->breadcrumbs = array (
		'Desafios' 
);

$this->menu = array (
		array (
				'label' => 'Criar Desafio',
				'url' => 'create'
		)
);
?>



<ul style="list-style-type: none;">
	<?php
		$challenges = Challenge::model ()->findAll ();
		foreach ( $challenges as $challenge ) {
			$challengeProposal = ChallengeHasProposal::model ()->findByAttributes ( array (
					'challenge_id' => $challenge->id,
					'result' => 'winner' 
			) );
			$image = Utils::findImageUrl ( $challengeProposal != null ? $challengeProposal->proposal->user->photo : 'default_image.jpg' );
			
			echo "<li style=\"padding-top:  50px; \">";
			
			echo "<a href=\"view/$challenge->id\">";

			echo "<div style=\" float: left; width: 100%; border-color: #8699a4; border-bottom: dotted \">";
			
			echo "<div style=\" float: left; width: 20%; text-align: center\">";
			echo "<img src=\"$image\" style=\"height: 100 px; width: 100px\">";
			echo "</div>";
			
			echo "<div style=\" float: right;  width: 80%;text-align: left\">";
			echo "<h2>$challenge->name</h2>";
			echo "<p> $challenge->name </p>";
			echo "</div>";
			
			echo "<div";
			echo "</a>";
			
			echo "</li>";
			echo "<br>";

		}
	?>
	
</ul>
